<html>
<head>
</head>
<body>
<h1> schedule</h1>
<?php
//following Doza's MySQL connection example I will highlight what this page does.
$conn = new mysqli('localhost','root','','SEVENBITS','3306');
if(mysqli_connect_errno()){
echo "connection failed";
}else {
echo "connection successful";
}
$sql = "SELECT * FROM roledate,wdate,roles,employees WHERE roledate.RoleID =roles.RoleID AND roledate.DateID = wdate.DateID AND employees.EmpID = roledate.EmpID";
$result = $conn->query($sql);
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
//this line narrows down the query to show a selected schedule based on the employee ID
if($row['EmpID']== $_GET["ID"]){
//this line shows information from the emplyee table and the roles tabel, the line after displays the 
//schedule asit is shown in the database.
echo "<br> id: " . $row['EmpID']."  ".$row['EmpFname']. " : " . $row['RoleName']. " : ";
echo"<br>" . $row['WDate'] . " : ". $row['ShiftStatus']."<br>" .$row['StartTime'] . "  -  " . $row['EndTime'] ."<br>";
//this link is specific taking 2 variables that are connected to the roledate table that can be used to adjust someones schedule
//an employee ID could be included to make the serch more specific to an employee but that will be shown in the next page
echo '<a href = "ShiftExchange.php?ID=' . urlencode($row['RoleID']), '&WDID='.urlencode($row['DateID']),'">put up shift to Market</a>';
}
}
}
else{
echo "no Shifts scheduled ";
}

$conn->close();


?>
</body>
</html>